<template>
  <div class="preview-container">
    <el-dialog
      title="预览文章"
      :visible="previewDialogVisible"
      width="900px"
      @close="closePreview"
    >
      <div class="title">
        <h2>{{ preview.title }}</h2>
      </div>
      <div class="info">
        <span>{{ preview.createTime | parseTimeByString }}</span>
        <span>{{ preview.username }}</span>
        <span class="el-icon-view" />
        <span>{{ preview.visits }}</span>
      </div>
      <div class="articleBody" v-html="preview.articleBody" />
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: 'Preview',
  props: {
    previewDialogVisible: {
      type: Boolean,
      default: false
    },
    preview: {
      type: Object,
      required: true
    }
  },
  methods: {
    closePreview() {
      this.$emit('update:previewDialogVisible', false)
    }
  }

}
</script>

<style scoped lang='scss'>
.preview-container{
  h2{
    margin: 0;
  padding: 0;
  }
.info{
padding-bottom: 10px;
}
   span{
    margin-left: 10px;
    margin-top: 10px;
  }
.articleBody{
  background-color: #f5f5f5;
  border-top: 1px dashed #ccc;
  padding:10px
}
}

</style>
